import OpenAI from "openai";

// const openai = new OpenAI({
//     baseURL: 'https://api.deepseek.com',
//     apiKey: 'sk-39c4af2246b9405d897f265750e62e08'
// });

// export const sendMessage = async (message:string)=>{
//     const response = await openai.chat.completions.create({
//         model: 'deepseek-chat',
//         messages:[
//             { role:'user', content:message }
//         ],
//         stream: true,
//     });
//     return response;
// }

class AiChat {
    private openai: OpenAI;

    private baseURL: string='https://api.deepseek.com';
    private apiKey: string='sk-39c4af2246b9405d897f265750e62e08';

    constructor() {
        this.openai = new OpenAI({
            baseURL: this.baseURL,
            apiKey: this.apiKey,
        });
    }

    public async doChat(message: string) {
        const stream = await this.openai.chat.completions.create({
            model: 'deepseek-chat',
            messages: [
                { role: 'user', content: message },
            ],
            stream: true,
        });
        return stream;
    }
}

export default AiChat;